/*
day118
2019.12.24
*/ 
#include <iostream>
using namespace std;

int n=4;

bool isBadVersion(int version)
{
	if(version>=n) return true;
	return false;
}

class Solution {
public:
    int firstBadVersion(int n) {
        int l=1,r=n;
        int mid;
        while(l<=n)
        {
        	mid=l+(r-l)/2;
        	if(isBadVersion(mid))
        	{
        		if(!isBadVersion(mid-1))
        		{
        			return mid;
				}
				else
				{
					r=mid-1;
				}
			}
			else
			{
				if(isBadVersion(mid+1))
				{
					return mid+1;
				}
				else
				{
					l=mid+1;
				}
			}
		}
		
		return mid;
    }
};

int main()
{
	return 0;
}
